package com.imooc;

import com.imooc.aspect.OutSide;
import com.imooc.service.AService;
import com.imooc.service.HelloService;
import com.imooc.service.HiService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Import;

@Configuration
@EnableAspectJAutoProxy(exposeProxy = true)
@Import(OutSide.class)
@ComponentScan("com.imooc")
public class Entrance {

	public static void main(String[] args) {
		ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Entrance.class);
		AService aService = applicationContext.getBean(AService.class);
		aService.say();

		applicationContext.getBean(HiService.class).sayHi();
		System.out.println("---------------------------分割线以下执行HelloService-------------------------------");
		HelloService helloService = applicationContext.getBean("helloServiceImpl", HelloService.class);
		helloService.sayHello();

		/*ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("classpath:spring/spring-config.xml");
		classPathXmlApplicationContext.getBean("hiServiceImpl", HiService.class).sayHi();*/
	}
}
